9
Importance of Data Structure Encapsulation
The principle of hiding the used data structure and to only provide a well-defined interface is known as encapsulation.
Example: define an ADT for complex numbers
Two parts:
•Real
•Imaginary
Operations:
•Addition
•Multiplication
•Subtraction
•Division
Version A: Both parts are stored in a two-valued record. If the element name of the real part is Re and that of the imaginary part is Im, x and y can be obtained with: x=c.Re and y=c.Im.
How represent data?